package demo;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import util.ConncetionUtil;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.ExecutionException;

public class Sender {
private static final String QUEUENAME="zfz";
    public static void main(String[] args) {
        Connection connection = ConncetionUtil.getConnection();

        try {
            //建立通道
            Channel channel = connection.createChannel();
            channel.queueDeclare(QUEUENAME,false,false,false,null);

            for (int i = 0; i <100 ; i++) {
                channel.basicPublish("",QUEUENAME,null,("刘艳星要请我吃饭"+i).getBytes(StandardCharsets.UTF_8));

            }
            //发布指令之后,生产者如果没有其他任务,就主动进行销毁
            channel.close();
            connection.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
